<%--
  Created by IntelliJ IDEA.
  User: root
  Date: 2020/12/13
  Time: 15:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>


<%

    // PageContext


    pageContext.setAttribute("name", "jshand");
    pageContext.setAttribute("age", "18",PageContext.PAGE_SCOPE);  //PageScope
    pageContext.setAttribute("address" ,"黑龙江",PageContext.REQUEST_SCOPE);//RequestScope

    // pageContext.setAttribute("key","pageContext-value");
    // request.setAttribute("key", "request-value");
    session.setAttribute("key", "session-value");
    application.setAttribute("key", "application-value");


%>

pageContext.getAttribute("name"); <%=pageContext.getAttribute("name")%>  <br>
pageContext.getAttribute("age"); <%=pageContext.getAttribute("age")%>  <br>

<%--查找作用域中是否存在 key--%>


查找所在的作用域 pageContext.getAttributesScope("address"): <%=pageContext.getAttributesScope("address")%>  <br>
在四大作用域中查找key对Value pageContext.findAttribute("address"): <%=pageContext.findAttribute("address")%> <br>


在四大作用域中查找key对Value pageContext.findAttribute("key"): <%=pageContext.findAttribute("key")%> <br>


</body>
</html>
